function varargout=state_space_lam(n,k,t,Q,H,Tea,Theta,Z)

% State Space system as in Harvey (1989)
% measurement equation: y(t) = d + Z alpha(t) + epsilon(t)
% transition equation: alpha(t+1) = c + T alpha(t) + R eta(t)
% with eta(t)~N(0,Q)
d=0;

Tea = [Tea,0];
if t==1
    Zcom = [Z(:,t)', 0]; % see Quasidiff_old.m for higher order lags
else
    Zcom = [Z(:,t)', -Z(:,t-1)'*Theta]; % see Quasidiff_old.m for higher order lags
end

[Tcom,Qcom]=VARcompanion(Tea,Q,0);

varargout(1) = {H};
varargout(2) = {Tea};
varargout(3) = {Tcom};
varargout(4) = {Q};
varargout(5) = {Qcom};
varargout(6) = {Zcom};
varargout(7) = {d};



